﻿<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        * {
            font-size: 12px;
        }

        textarea {
            width: 400px;
            height: 150px;
            border-radius: 5px;
        }

        span {
            display: table;
        }

        .center {
            display: inline-block;
            float: left;
        }
    </style>

</head>

<body>
    <div class="center">
        <select id="select_id" style="width:100px">
            <option value="join">验证用户</option>
            <option value="sendMessage">发送消息</option>
            <option value="queryMessage">查询消息</option>
            <option value="updateMessageReadStatus">更新消息状态</option>
            <option value="deleteMessage">删除消息</option>
        </select>
        <input type="button" name="name" value="调用方法" class="call" />

        <span>参数</span>
        <textarea name="data" id="data_id"></textarea>

        <div></div>
        <textarea name="result" id='result_id' style="height:300px;"></textarea>
    </div>

    <div class="center">
        验证消息示例:
        <pre>
            {
                "userId": 10000, 
                "appId": 123, 
                "time": 1513763887939,
                "md5": "ce8fcf995cef5d433f6c3eef53114f3c"
            }
        </pre>
    </div>
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="http://10.0.0.234:8008/socket.io/socket.io.js"></script>
    <script src="http://10.0.0.234:8008/main.js"></script>
    <script type="text/javascript">

        $(function () {
            $('.call').click(function () {
                var paramValue = $("#data_id").val();

                if (!paramValue) {
                    alert('请填写参数!');
                    return;
                }

                var fnName = $("#select_id").val();
                var $result = $("#result_id");

                var jsonValue = $.parseJSON(paramValue);

                msgTool[fnName](jsonValue, function (data) {
                    $result.val(JSON.stringify(data));
                });
            });
        });

        msgTool.receiveMessageFn = function (data) {
            console.log(data);
        };
    </script>
</body>
</html>